package top.mhtools.pigeon.ding.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import top.mhtools.pigeon.common.enums.SendTypeEnum;
import top.mhtools.pigeon.common.persistence.SendMessageRequest;
import top.mhtools.pigeon.wechat.dto.WeChatMessageReqDTO;

import java.util.Map;

/**
 * 钉钉消息入参类
 *
 * @author machen
 * @date 2020/5/25 13:03
 */
@Data
public class DingMessageReqDTO extends BaseDingMessageDTO implements SendMessageRequest {

    @ApiModelProperty(value = "markdown消息入参")
    private Markdown markdown;

    @ApiModelProperty(value = "text消息入参")
    private TextDTO text;

    private LinkDTO link;

    @Data
    public static class Markdown {
        @ApiModelProperty(value = "首屏会话透出的展示内容", required = true)
        private String title;

        @ApiModelProperty(value = "markdown格式的消息")
        private String text;

        @ApiModelProperty(value = "搭配模板使用")
        private Map<String, Object> textMap;
    }

    @Data
    public static class TextDTO {
        @ApiModelProperty(value = "消息内容", required = true)
        private String content;
    }

    @Data
    public static class LinkDTO {
        private String text;
        private String title;
        private String picUrl;
        private String messageUrl;
    }

    @Override
    public String getSendType() {
        return SendTypeEnum.DING_TALK.getName();
    }

    @Override
    public DingMessageReqDTO getDingMessageReqDTO() {
        return this;
    }

    @Override
    public WeChatMessageReqDTO getWeChatMessageReqDTO() {
        return null;
    }
}
